<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="common/header.jsp" %>
<div id="main" class="wrap">
	<%@ include file="common/left.jsp" %>
	<script type="text/javascript">
	var search=function(pageCode){
		$.ajax({
			url:"../ProductmServlet",
			type:"post",
			 dataType:"json",
			 data:{
				 currpage:pageCode,
				 op:"queryAllProducts"
			 },
			 success : function(data){
					$("#pro").html('');
					$.each(data.beanList,function(idx,pro){
						$("#pro").append("<tr><td class='first w4 c'>"+(idx+1)+"</td><td class='thumb'><img src='${ctx}/images/product/0_tiny.gif' /><a href='${ctx}/ProductmServlet?op=prefindProById&pid="+pro.pid+"' target='_self'>"+pro.pname+"</a></td><td class='w1 c'><a href='${ctx}/ProductmServlet?pid="+pro.pid+"&op=findProById'>修改</a> <a class='manageDel' href='${ctx}/ProductmServlet?pid="+pro.pid+"&op=delpro'>删除</a></td></tr>");
					});
					  laypage({
							cont : 'fenye',  //容器id：存放分页
							pages : data.totalPage, //得到总页数
							curr:  data.pageCode || 1,  //当前页
							skip: true, //是否开启跳页
							skin: '#AF0000',  //页码的颜色
							groups: 5,  //
							jump : function(obj, first) {
								if (!first) {   //首次加载不执行，并传递当前页：obj.curr
									search(obj.curr);  //调用函数
								}
							}
						}); 		
			 }
		})		
	}
	$(function(){
	search(1);		
	})
	function delBook(id,name){
		if(confirm("是否确定删除"+name+"?")){
			location.href="${ctx}/ProductmServlet?pid="+id+"&op=delpro";
		}
	}
	</script>
	<div class="main">
		<h2 id="ss">商品管理</h2>
		<h3 style="text-align : right"><a href="${ctx}/ProductmServlet?op=getproList">新增</a></h3>
		<div class="manage">
			<table class="list">
				<tr>
					<th>编号</th>
					<th>商品名称</th>
					<th>操作</th>
				</tr>
			</table>
			<table id="pro" class="list"></table>
			<div id="fenye"></div>
		</div>
	</div>
</div>
<%@ include file="common/foot.jsp"%>